import java.util.Iterator;
import java.util.LinkedHashSet;

public class LinkedHashSetTest {
    public static void main(String[] args) {
        LinkedHashSet<Person> hashSet = new LinkedHashSet<>();

        Person p1 = new Person("abc", 18);
        Person p2 = new Person("abc", 24);
        Person p3 = new Person("def", 18);
        Person p4 = new Person("xy", 36);

        hashSet.add(p1);
        hashSet.add(p2);
        hashSet.add(p3);
        hashSet.add(p4);

        Iterator<Person> iterator = hashSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

    }
}
